sum of beauty of all substrings